import { Router } from "express";
import { verifyToken } from "../utils/jwt.js";
import {
  getChatHistory,
  getChatList,
  sendMessage,
  createRoom,
  getRoomList,
  getRoomDetail,
  getRoomHistory,
  deleteRoom,
} from "../controllers/chatController.js";

const router = Router();

// 私聊相关路由
// 获取聊天列表
router.get("/list", verifyToken(), getChatList);
// 获取聊天历史
router.get("/:uId/history", verifyToken(), getChatHistory);
// 发送消息
router.post("/send", verifyToken(), sendMessage);

// 群聊相关路由
// 创建群聊
router.post("/room", verifyToken(), createRoom);
// 获取群聊列表
router.get("/room/list", verifyToken(), getRoomList);
// 获取群聊详情
router.get("/room/:rId", verifyToken(), getRoomDetail);
// 获取群聊消息历史
router.get("/room/:rId/history", verifyToken(), getRoomHistory);
// 删除群聊
router.delete("/room/:rId", verifyToken(), deleteRoom);

export default router;
